<?php $this->fetch('public/head') ?>
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">

        <li ><a href="<?php echo url('make/index') ?>">生产工艺流程</a></li>
        <li class="layui-this"><a href="<?php echo url('make/index2') ?>">品质监控</a></li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" action="<?php echo url('make/index2') ?>" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" value="<?php echo $rows['title'] ?>" required lay-verify="required" placeholder="请输入我们的荣誉" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">英文标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title_en" value="<?php echo $rows['title_en'] ?>" required lay-verify="required" placeholder="请输入我们的荣誉" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">展示图片</label>
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" id="img2"><i class="layui-icon">&#xe67c;</i>图集上传</button>
                        <div id="photo-container">
                            <?php foreach($photo as $v): ?>
                                <div class="photo-list">
                                    <input type="text" name="tit[]" value="<?php echo $v['tit'] ?>" class="layui-input layui-input-inline">
                                    <input type="text" name="tit_en[]" value="<?php echo $v['tit_en'] ?>" class="layui-input layui-input-inline">
                                    <input type="text" name="photo[]" value="<?php echo $v['img'] ?>" class="layui-input layui-input-inline">
                                    <button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button>
                                    &nbsp;<img src="<?php echo $v['img'] ?>" height="38" class="layui-upload-img" data-expander='default,diamond,turn3d,flip3d,rotate,fade'></div>
                            <?php endforeach; ?>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $this->fetch('public/script') ?>

<script type="text/javascript">
    function jia(obj){
        var str = '<span><br><br><input type="text" name="jieshao[xx][]" required lay-verify="required" class="layui-input layui-input-inline"><i onclick="jian(this)" class="layui-icon layui-btn">&#xe640;</i></span>';
        $(obj).parent().append(str)
    }
    function jian(obj){
        $(obj).parent().remove();
    }
</script>
<script type="text/javascript">
    layui.use('upload', function(){
        var upload = layui.upload;
        //多图片上传
        upload.render({
            elem: '#img2',
            url: '<?php echo url('hsjson/upload') ?>',
            multiple: true,
            done: function(res){
                //如果上传失败
                if(res.error > 0){
                    return layer.msg(res.message);
                }
                //上传完毕
                photoListItem = '<div class="photo-list"><input type="text" name="tit[]" value="" class="layui-input layui-input-inline"><input type="text" name="tit_en[]" value="" class="layui-input layui-input-inline"><input type="text" name="photo[]" value="' + res.url + '" class="layui-input layui-input-inline">';
                photoListItem += '<button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button>';
                photoListItem += '&nbsp;<img src="'+ res.url +'" height="38" class="layui-upload-img"></div>'
                $('#photo-container').append(photoListItem).on('click', '.remove-photo-btn', function () {
                    $(this).parent('.photo-list').remove();
                });
            }
        });
    })
    $('#photo-container').on('click', '.remove-photo-btn', function () {
        $(this).parent('.photo-list').remove();
    });
</script>